<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model backend\models\GraduationAudit */

$this->title = $model->BYND . '年毕业生毕业证书验印审核表';
$this->params['breadcrumbs'][] = ['label' => '毕业资格审核', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
?>
<div class="graduation-audit-view">

    <div class="panel">
		<div class="panel-heading no-print">
            <?= Html::encode($this->title) ?>            
            <div class="pull-right">                
                <button id="btn-preview" class="btn btn-sm btn-cyan" title="预览">预览</button>          
                <button id="btn-print" class="btn btn-sm btn-cyan" title="打印验印审核表">打印本页</button>
                <button id="btn-print-all" class="btn btn-sm btn-cyan" title="打印验印审核表，以及资格审核与验印登记表">打印全部</button>      
            </div>
		</div>
        <div class="panel-body text-center">  
            <div class="page text-left">
                <h3>附件3</h3>
                <h1 class="text-center"><?= Html::encode($this->title) ?></h1>
                <br/>

                <p class="clearfix">
                    <span class="pull-left">学校名称（盖章）: <?= Html::encode($model->XXMC) ?></span>
                    <span class="pull-right" style="width:20em">学校负责人盖章: </span>
                </p>
                
                <table id="t1" class="table table-bordered">
                    <thead>
                        <tr>
                            <td rowspan="2">毕业生总数</td>
                            <td colspan="6" style="text-align:left">其中:</td>
                        </tr>
                        <tr>
                            <td>专业名称</td>
                            <td>入校时间</td>
                            <td>学制</td>
                            <td>教学形式</td>
                            <td>毕业人数</td>
                            <td>毕业证书编号起止号</td>
                        </tr>
                    </thead>
                    <?php $graduationEligibleAudits = $model->graduationEligibleAudits; ?>
                    <tbody>
                        <tr>
                            <td rowspan="<?= sizeof($graduationEligibleAudits) ?>">
                                <?= $model->BYRS ?>
                            </td>
                        <?php foreach($graduationEligibleAudits as $item) {
                                 $data = $item->getGraduationEligibleStudents()
                                        ->select([
                                            'count' => "count(*)",
                                            'MIN_BYZBH' =>"min(BYZBH)", 
                                            'MAX_BYZBH' => "max(BYZBH)"
                                        ])
                                        ->asArray()
                                        ->one();
                            ?>
                            <td><?= Html::a($item->ZYMC, ['graduation-eligible-audit/view', 'id'=>$item->ID]) ?></td>
                            <td><?= Yii::$app->formatter->asDate($item->RXSJ, 'php:Y 年 n 月') ?></td>
                            <td><?= Html::encode($item->XZ) ?></td>
                            <td><?= Html::encode($item->JXXS) ?></td>
                            <td><?= $data['count'] ?></td>
                            <td><?= $data['MIN_BYZBH']  ?> - <?= $data['MAX_BYZBH'] ?></td>
                        </tr>
                        <tr>
                        <?php } ?>
                            <td>学校经办人</td>
                            <td colspan="2"><?= Html::encode($model->JBRXM) ?></td>
                            <td colspan="2">联系电话</td>
                            <td colspan="2"><?= Html::encode($model->JBRDH) ?></td>
                        </tr>        
                    </tbody>
                    <tfoot>
                        <tr>
                            <?php $date = '　　　　年　　月　　日'; ?>
                            <td colspan="2" class="opinion">
                                市教育局成称科审核意见：<br/>
                                <div class="content">
                                    <?= Html::encode($model->SJYJYJ) ?>
                                </div>
                                <div class="date">
                                    <?= $model->SJYJRQ ? date('Y 年 m 月 d 日', $model->SJYJRQ) : $date ?>
                                </div>
                            </td>
                            <td colspan="3" class="opinion">
                                自治区验印审核人：<br/>
                                <div class="content">
                                    <?= Html::encode($model->ZZQYYR) ?>
                                </div>
                                <div class="date">
                                    <?= $model->ZZQYYRQ ? date('Y 年 m 月 d 日', $model->ZZQYYRQ) : $date ?>
                                </div>
                            </td>
                            <td colspan="2" class="opinion">
                                自治区教育厅审核意见：<br/>
                                <div class="content">
                                    <?= Html::encode($model->QJYTYJ) ?>
                                </div>
                                <div class="date">
                                    <?= $model->QJYTRQ ? date('Y 年 m 月 d 日', $model->QJYTRQ) : $date ?>
                                </div>
                            </td>
                        </tr>    
                        <tr>    
                            <td colspan="2" class="text-center">
                                自治区教育厅监印人
                            </td>
                            <td colspan="5" class="opinion">
                                <?= Html::encode($model->QJYTJYR) ?>
                                <span class="date pull-right">
                                    <?= $model->QJYTJYRQ ? date('Y 年 m 月 d 日', $model->QJYTJYRQ) : $date ?>
                                </span>
                            </td>
                        </tr>    
                    </tfoot>        
                </table>
                
                <p>
                    填写说明：1.毕业生人数须与附件1所填一致。<br/>
                    　　　　　2.专业名称、入学人数、学制、教学形式须与附件2所填一致。
                </p>
            </div>
        </div>
    </div>
        
<style>
#t1 thead td,
#t1 tbody td{
    text-align:center;
    vertical-align:middle;
    white-space: nowrap;
}
#t1 tbody td:last-child{
    white-space: normal;
    padding: 0;
    line-height: 1em;
}
.opinion .content{
    height:6em;
}
.opinion .date{
    text-align:right;
    margin-right:2em;
}

.page{
    padding: 2cm 1cm;
    background-color: white;
}
.page.preview{
    width: 210mm;
    height: 271mm;
    margin: 0 auto 20px;
    border: 1px solid #ccc;
    box-shadow: 1px 1px 5px gray;
}
.preview *{
    color: black;
    border-color: black !important;
}
.preview thead td{
    border-bottom-width:1px !important;
}

@media print{
    .no-print{
        display: none;
    }
    .wrap, .wrap .container,
    .panel, .panel-body{
        margin:0;
        padding:0;
    }
    .page{    
        margin: 0 auto !important;
        border: none !important;
        box-shadow: none !important;
        page-break-after: always;
    }
    .page:first-of-type{ 
        page-break-after: avoid;
    }
    .table.table-bordered,
    .table.table-bordered td,
    .table.table-bordered th{
        border-color: black !important;
        border-top-color: black !important;
        border-left-color: black !important;
        border-right-color: black !important;
        border-bottom-color: black !important;
    }
    a[href]::after{
        display:none
    }
}
</style>

<script>
    <?php $this->beginBlock('my_js'); ?>
    $('#btn-print').click(function(){
        window.print();
    });
    
    $('#btn-preview').click(function(){
        $('.page').toggleClass('preview');
    });
    <?php $this->endBlock(); ?>
    <?php $this->registerJs($this->blocks['my_js']); ?>
<script>


</div>
